<template>
	<view class="container">
		<view class="main">
			<view class="list flex flex-align flex-bt">
				<input type="nickname" :placeholder="'请输入'+name"  @blur="getName">
			</view>
		</view>
		<view class="wenzi grey">限2-16个字符</view>
		<view class="btn hei baocun" @click="postData">保存</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello',
				nickname:'',
				type:'',
				name:''
			}
		},
		onLoad(e) {
			this.type= e.type
			this.name = e.name
			uni.setNavigationBarTitle({
				title: e.name
			})
		},
		methods: {
			getName(e){
				console.log(e.detail.value)
				this.nickname = e.detail.value
			},
			postData(){
				let that = this
				let data ={}
				if(that.type==1){
					data = {nickname:that.nickname}
				}else if(that.type==2){
					data = {wechat:that.nickname}
				}else if(that.type==3){
					data = {signature:that.nickname}
				}else if(that.type==4){
					data = {username:that.nickname}
				}
				console.log(data)
				that.tui.request("api.auth.center/set", "PUT",data , false, true, false).then((res) => {
					
					that.tui.toast(res.info)
					if(res.code==1){
						setTimeout(()=>{
							uni.navigateBack()
						},1500)
					}
					
				}).catch((res) => {})
			},
		}
	}
</script>

<style lang="scss">
	page{background: #f5f5f5;padding-top: 30rpx;}
	.grey{color: #b3b3b3;}
	.main{padding: 0 40rpx;background: #fff;
		.list{border-bottom: 1px solid #eee;height: 100rpx;
			input{font-size: 26rpx;}
		}
		.list:last-child{border-bottom: none;}
	}
	.wenzi{padding:20rpx 30rpx;}
	.baocun{margin: 60rpx 30rpx;border-radius: 6rpx;}
	.btn{background: #bbe68c;color: #fff;text-align: center;line-height: 90rpx;}
</style>